//
//  SKMeViewController.m
//  loveKangaroo
//
//  Created by SeeKool on 15/3/3.
//  Copyright (c) 2015年 SeeKool Inc. All rights reserved.
//

#import "SKMeViewController.h"
#import "SKGoodsStorageView.h"
#import "SKShopPlanView.h"
#import "SKWishListView.h"

@interface SKMeViewController ()
@property (nonatomic, weak) UIScrollView *scrollView;
@end

@implementation SKMeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"大包小包的女孩儿";
    //袋鼠
    UIButton *kangaroo = [UIButton buttonWithType:UIButtonTypeCustom];
    [kangaroo setTitle:@"袋鼠" forState:UIControlStateNormal];
    [kangaroo setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];
    kangaroo.frame = CGRectMake(20, 20, 90, 80);
    [kangaroo setBackgroundColor:[UIColor redColor]];
    [self.view addSubview:kangaroo];
    
    //头像
    UIButton *userHead = [UIButton buttonWithType:UIButtonTypeCustom];
    [userHead setTitle:@"五袋长老" forState:UIControlStateNormal];
    [userHead setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];
    userHead.frame = CGRectMake(100, 20, 90, 90);
    userHead.centerX = ScreenWidth * 0.5;
    [userHead setBackgroundColor:[UIColor redColor]];
    [self.view addSubview:userHead];
    
    //好友来信
    UIButton *message = [UIButton buttonWithType:UIButtonTypeCustom];
    [message setTitle:@"好友来信" forState:UIControlStateNormal];
    [message setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];
    message.frame = CGRectMake(ScreenWidth - 110, 20, 90, 80);
    [message setBackgroundColor:[UIColor redColor]];
    [self.view addSubview:message];
    
    //用户等级
    for (int i = 0; i < 5; i++) {
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        
        CGFloat btnX = 90 + i * (30 + 3);
        btn.frame = CGRectMake(btnX, 120, 30, 30);
        [btn setBackgroundColor:[UIColor redColor]];
        [self.view addSubview:btn];
    }
    UILabel *userLevel = [[UILabel alloc] init];
    userLevel.backgroundColor = [UIColor redColor];
    userLevel.textAlignment = NSTextAlignmentCenter;
    userLevel.frame = CGRectMake(140, 160, 90, 30);
    userLevel.text = @"五代长老";
    [self.view addSubview:userLevel];
    
    for (int i = 0; i < 3; i++) {
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.tag = i;
        CGFloat btnStartX = 30;
        CGFloat btnWidth = (ScreenWidth - btnStartX * 2) / 3;
        CGFloat btnX = btnStartX + i * (btnWidth + 3);
        btn.frame = CGRectMake(btnX, CGRectGetMaxY(userLevel.frame) + 10, btnWidth, 30);
        [btn setTitle:[NSString stringWithFormat:@"%d", i + 1] forState:UIControlStateNormal];
        [btn setBackgroundColor:[UIColor redColor]];
        [btn addTarget:self action:@selector(switchView:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:btn];
        
    }
    UIScrollView *scrollView = [[UIScrollView alloc] init];
    scrollView.contentSize = CGSizeMake(ScreenWidth * 3, 600);
    scrollView.bounces = NO;
    scrollView.pagingEnabled = YES;
    scrollView.scrollEnabled = NO;
    scrollView.frame = CGRectMake(0, CGRectGetMaxY(userLevel.frame) + 50, ScreenWidth, 300);
    self.scrollView = scrollView;
    [scrollView setBackgroundColor:[UIColor lightGrayColor]];
    [self.view addSubview:scrollView];
    //商品库
    SKGoodsStorageView *goodsStorageView = [[SKGoodsStorageView alloc] init];
    goodsStorageView.frame = CGRectMake(0, 0, ScreenWidth, 300);
    [scrollView addSubview:goodsStorageView];
    //购物计划
    SKShopPlanView *shopPlanView = [[SKShopPlanView alloc] init];
    shopPlanView.frame = CGRectMake(ScreenWidth, 0, ScreenWidth, 300);
    [scrollView addSubview:shopPlanView];
    //心愿单
    SKWishListView *wishListView = [[SKWishListView alloc] init];
    wishListView.frame = CGRectMake(ScreenWidth * 2, 0, ScreenWidth, 300);
    [scrollView addSubview:wishListView];
}
- (void)switchView:(UIButton *)btn{
    
    NSInteger currentPage = btn.tag;
    
    CGFloat offSetX = currentPage * ScreenWidth;
    
    self.scrollView.contentOffset = CGPointMake(offSetX, 0);
}


@end
